#include <iostream>
using namespace std;
typedef long long ll;

// 扩展欧几里得算法
ll exgcd(ll a, ll b, ll &x, ll &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  ll d = exgcd(b, a % b, x, y);
  ll t = x;
  x = y;
  y = t - a / b * y;
  return d;
}

int main() {
  ios::sync_with_stdio(false);
  ll start1, start2, interval1, interval2;
  cin >> start1 >> start2 >> interval1 >> interval2;

  ll k1, k2;
  ll d = exgcd(interval1, -interval2, k1, k2);

  // 检查是否有解
  if ((start2 - start1) % d != 0) {
    cout << "Impossible" << endl;
    return 0;
  }

  // 计算最小正整数解
  ll scale = (start2 - start1) / d;
  k1 *= scale;
  k2 *= scale;

  // 计算最小非负解
  ll mod1 = abs(interval2 / d);
  k1 = (k1 % mod1 + mod1) % mod1;

  ll mod2 = abs(interval1 / d);
  k2 = (k2 % mod2 + mod2) % mod2;

  // 计算两个可能的时间
  ll time1 = start1 + k1 * interval1;
  ll time2 = start2 + k2 * interval2;

  // 输出最早满足条件的时间
  ll earliest_time = max(time1, time2);
  cout << earliest_time << endl;

  return 0;
}
